/**
 * Created by Administrator on 2019/8/19.
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'visit/visiting/index' + location.search,
                    add_url: 'visit/visiting/add',
                    edit_url: 'visit/visiting/edit',
                    del_url: 'visit/visiting/del',
                    multi_url: 'visit/visiting/multi',
                    table: 'visiting',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                visible: false,
                showToggle: false,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'user_id', title: __('User_id'),operate:false},
                        {field: 'name', title: __('Name')},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'venue', title: __('Venue')},
                        {field: 'company',operate:'LIKE',title: __('Company')},
                        {field: 'department',operate:'LIKE', title: __('Department')},
                        {field: 'position_type', title: __('Position_type'),operate:false},
                        {field: 'views', title: __('Views'),operate:false,operate:false},
                        {field: 'actual_views', title: __('Actual_views'),operate:false,operate:false},
                        {field: 'admin.nickname', title: __('讲解员'),operate:false},
                        {field: 'day', title: __('Day'),operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.date},
                        {field: 'between_time', title: __('Between_time'),searchList: {"0":__('9:00-10:00'),"1":__('10:00-11:00'),"2":__('11:00-12:00'),"3":__('12:00-13:00'),"4":__('13:00-14:00'),"5":__('14:00-15:00'),"6":__('15:00-16:00')},formatter: Table.api.formatter.normal},
                        {field: 'between_day', title: __('Between_day'),operate:false},
                        {field: 'status', title: __('预约状态'),searchList: {"0":__('等待预约'),"1":__('预约中'),"2":__('完成预约'),"3":__('取消预约')},formatter: Table.api.formatter.normal},
                        {field: 'note', title: __('Note'),operate:false},
                        {field: 'reason', title: __('Reason'),operate:false},
                        {field: 'add_time', title: __('Add_time'),operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.timestamp,operate:false},
                        {field: 'code', title: __('验证码'),operate:false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
